package com.example.yunifang.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.graphics.Paint;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.yunifang.R;
import com.example.yunifang.bean.HeaderViewPagerBean.Data.GroupBriefs.BirefList1;
import com.nostra13.universalimageloader.core.ImageLoader;

public class MyGridView2Adapter extends BaseAdapter {
	ArrayList<BirefList1> data;
	Context context;

	public MyGridView2Adapter(ArrayList<BirefList1> data, Context context) {
		super();
		this.data = data;
		this.context = context;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return data.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return data.get(arg0);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder=null;
		if(convertView==null){
			convertView=View.inflate(context, R.layout.my_grid_item_gd2, null);
			holder=new ViewHolder();
			holder.img=(ImageView) convertView.findViewById(R.id.my_grid_item_gd2_img);
			holder.name=(TextView) convertView.findViewById(R.id.my_grid_item_gd2_name);
			holder.market_price=(TextView) convertView.findViewById(R.id.my_grid_item_gd2_price_in);
			holder.price=(TextView) convertView.findViewById(R.id.my_grid_item_gd2_price);
			convertView.setTag(holder);
		}else{
			holder=(ViewHolder) convertView.getTag();
		}
		ImageLoader.getInstance().displayImage(data.get(position).goods_img, holder.img);
		holder.name.setText(data.get(position).goods_name);
		holder.market_price.setText(data.get(position).market_price+"");
		holder.price.setText(data.get(position).shop_price+"");
		holder.market_price.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG |Paint.ANTI_ALIAS_FLAG);
		return convertView;
	}
	public class ViewHolder{
		ImageView img;
		TextView name;
		TextView price;
		TextView market_price;
	}

}
